package com.venusj.test;

import com.venusj.service.HelloService;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;

/**
 * @author venusj
 * @date 2020/12/7
 * 动态扩展点选择实现
 */
public class DubboAdaptiveMain {
    public static void main(String[] args) {
        // 通过在url后缀指定扩展点 ?hello.service=dog
//        URL url = URL.valueOf("test://localhost/hello?hello.service=dog");

        // 通过@SPI里面参数指定动态扩展点
        URL url = URL.valueOf("test://localhost/hello");
        HelloService helloService = ExtensionLoader.getExtensionLoader(HelloService.class).getAdaptiveExtension();

        String msg = helloService.sayHello(url);

        System.out.println(msg);
    }
}
